package org.jzentest.filetracker;

import java.io.File;
import java.io.FileFilter;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Lister {
	public List<File> getFileListingNoSort(File aStartingDir)
			throws FileNotFoundException {
		List<File> result = new ArrayList<File>();
		File[] filesAndDirs = aStartingDir.listFiles(new FileFilter(){
			public boolean accept(File pathname) {
				return pathname.isDirectory() || pathname.getName().endsWith(".class");
			}});
		
		List<File> filesDirs = Arrays.asList(filesAndDirs);
		for (File file : filesDirs) {
			if (file.isDirectory()) {
				List<File> deeperList = getFileListingNoSort(file);
				result.addAll(deeperList);
			} else {
				result.add(file);
			}
		}
		return result;
	}

}
